Skip to content

Conversation

@evelez7
Copy link
Member

@evelez7 evelez7 commented Jul 18, 2025

The Mustache basic project has comments in its headers but the comments were not
serialized. Now we serialize @brief and paragraph comments for classes
and add that output to the basic project test.

Copy link
Member Author

evelez7 commented Jul 18, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@evelez7 evelez7 marked this pull request as ready for review July 18, 2025 19:07
@llvmbot
Copy link
Member

llvmbot commented Jul 18, 2025

@llvm/pr-subscribers-clang-tools-extra

Author: Erick Velez (evelez7)

Changes

The Mustache basic project has comments in its headers but the comments were not
serialized. Now we serialize @brief and paragraph comments for classes
and add that output to the basic project test.


Full diff: https://github.com/llvm/llvm-project/pull/149565.diff

3 Files Affected:

  • (modified) clang-tools-extra/clang-doc/assets/class-template.mustache (+2-2)
  • (modified) clang-tools-extra/clang-doc/assets/comment-template.mustache (+7-2)
  • (modified) clang-tools-extra/test/clang-doc/basic-project.mustache.test (+43)
diff --git a/clang-tools-extra/clang-doc/assets/class-template.mustache b/clang-tools-extra/clang-doc/assets/class-template.mustache
index a4077323f29e2..b1a7470f7c33a 100644
--- a/clang-tools-extra/clang-doc/assets/class-template.mustache
+++ b/clang-tools-extra/clang-doc/assets/class-template.mustache
@@ -128,11 +128,11 @@
             <section class="hero section-container">
                 <div class="hero__title">
                     <h1 class="hero__title-large">{{TagType}} {{Name}}</h1>
-                    {{#RecordComments}}
+                    {{#Description}}
                     <div class="hero__subtitle">
                         {{>Comments}}
                     </div>
-                    {{/RecordComments}}
+                    {{/Description}}
                 </div>
             </section>
             {{#HasPublicMembers}}
diff --git a/clang-tools-extra/clang-doc/assets/comment-template.mustache b/clang-tools-extra/clang-doc/assets/comment-template.mustache
index 723ace7a0eed1..b793bad55cf6c 100644
--- a/clang-tools-extra/clang-doc/assets/comment-template.mustache
+++ b/clang-tools-extra/clang-doc/assets/comment-template.mustache
@@ -5,11 +5,16 @@
     
     This file defines templates for generating comments
 }}
-{{#FullComment}}
+{{#BriefComments}}
     {{#Children}}
     {{>Comments}}
     {{/Children}}
-{{/FullComment}}
+{{/BriefComments}}
+{{#ParagraphComments}}
+    {{#Children}}
+    {{>Comments}}
+    {{/Children}}
+{{/ParagraphComments}}
 {{#ParagraphComment}}
     {{#Children}}
     {{>Comments}}
diff --git a/clang-tools-extra/test/clang-doc/basic-project.mustache.test b/clang-tools-extra/test/clang-doc/basic-project.mustache.test
index 4dd6f4165f65e..4fb38e2b32fcb 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.mustache.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.mustache.test
@@ -60,6 +60,17 @@ HTML-SHAPE:         <div class="content">
 HTML-SHAPE:             <section class="hero section-container">
 HTML-SHAPE:                 <div class="hero__title">
 HTML-SHAPE:                     <h1 class="hero__title-large">class Shape</h1>
+HTML-SHAPE:                    <div class="hero__subtitle">
+HTML-SHAPE:                                    <div>
+HTML-SHAPE:                                        <p> Abstract base class for shapes.</p>
+HTML-SHAPE:                                    </div>
+HTML-SHAPE:                                        <div>
+HTML-SHAPE:                                    <p></p>
+HTML-SHAPE:                                </div>
+HTML-SHAPE:                                    <div>
+HTML-SHAPE:                                    <p> Provides a common interface for different types of shapes.</p>
+HTML-SHAPE:                                </div>
+HTML-SHAPE:                                                </div>
 HTML-SHAPE:                 </div>
 HTML-SHAPE:             </section>
 HTML-SHAPE:             <section id="PublicMethods" class="section-container">
@@ -172,6 +183,16 @@ HTML-CALC:         <div class="content">
 HTML-CALC:             <section class="hero section-container">
 HTML-CALC:                 <div class="hero__title">
 HTML-CALC:                     <h1 class="hero__title-large">class Calculator</h1>
+HTML-CALC:                                    <div>
+HTML-CALC:                                        <p> A simple calculator class.</p>
+HTML-CALC:                                    </div>
+HTML-CALC:                                        <div>
+HTML-CALC:                                    <p></p>
+HTML-CALC:                                </div>
+HTML-CALC:                                    <div>
+HTML-CALC:                                    <p> Provides basic arithmetic operations.</p>
+HTML-CALC:                                </div>
+HTML-CALC:                                                </div>
 HTML-CALC:                 </div>
 HTML-CALC:             </section>
 HTML-CALC:             <section id="PublicMembers" class="section-container">
@@ -300,6 +321,17 @@ HTML-RECTANGLE:         <div class="content">
 HTML-RECTANGLE:             <section class="hero section-container">
 HTML-RECTANGLE:                 <div class="hero__title">
 HTML-RECTANGLE:                     <h1 class="hero__title-large">class Rectangle</h1>
+HTML-RECTANGLE:                    <div class="hero__subtitle">
+HTML-RECTANGLE:                                    <div>
+HTML-RECTANGLE:                                        <p> Rectangle class derived from Shape.</p>
+HTML-RECTANGLE:                                    </div>
+HTML-RECTANGLE:                                        <div>
+HTML-RECTANGLE:                                    <p></p>
+HTML-RECTANGLE:                                </div>
+HTML-RECTANGLE:                                    <div>
+HTML-RECTANGLE:                                    <p> Represents a rectangle with a given width and height.</p>
+HTML-RECTANGLE:                                </div>
+HTML-RECTANGLE:                                                </div>
 HTML-RECTANGLE:                 </div>
 HTML-RECTANGLE:             </section>
 HTML-RECTANGLE:             <section id="PublicMethods" class="section-container">
@@ -395,6 +427,17 @@ HTML-CIRCLE:         <div class="content">
 HTML-CIRCLE:             <section class="hero section-container">
 HTML-CIRCLE:                 <div class="hero__title">
 HTML-CIRCLE:                     <h1 class="hero__title-large">class Circle</h1>
+HTML-CIRCLE:                    <div class="hero__subtitle">
+HTML-CIRCLE:                                    <div>
+HTML-CIRCLE:                                        <p> Circle class derived from Shape.</p>
+HTML-CIRCLE:                                    </div>
+HTML-CIRCLE:                                        <div>
+HTML-CIRCLE:                                    <p></p>
+HTML-CIRCLE:                                </div>
+HTML-CIRCLE:                                    <div>
+HTML-CIRCLE:                                    <p> Represents a circle with a given radius.</p>
+HTML-CIRCLE:                                </div>
+HTML-CIRCLE:                                                </div>
 HTML-CIRCLE:                 </div>
 HTML-CIRCLE:             </section>
 HTML-CIRCLE:             <section id="PublicMethods" class="section-container">

The Mustache basic project has comments in its headers but the comments were not
serialized. Now we serialize @brief and paragraph comments for classes
and add that output to the basic project test.
@evelez7 evelez7 force-pushed the users/evelez7/clang-doc-revamp-comments branch from 959b078 to 0e6eaa3 Compare July 18, 2025 19:13
@evelez7 evelez7 force-pushed the users/evelez7/clang-doc-class-comments branch from 5c0f493 to 4a076ea Compare July 18, 2025 19:13
@evelez7 evelez7 requested review from ilovepi and petrhosek July 18, 2025 19:48
Comment on lines +63 to +73
HTML-SHAPE: <div class="hero__subtitle">
HTML-SHAPE: <div>
HTML-SHAPE: <p> Abstract base class for shapes.</p>
HTML-SHAPE: </div>
HTML-SHAPE: <div>
HTML-SHAPE: <p></p>
HTML-SHAPE: </div>
HTML-SHAPE: <div>
HTML-SHAPE: <p> Provides a common interface for different types of shapes.</p>
HTML-SHAPE: </div>
HTML-SHAPE: </div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any notion about why the format w/ the tags is so wonky? The template looks fine. Are we handling whitespace incorrectly in the mustache lib? or do we need to format the template differently to get these to line up correctly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only happens in the comment partial. I'm pretty sure it's something in the mustache library because all other templates handle their whitespace fine.

I also haven't tested it but the comment partial is the only one that templates itself recursively, so that might have something to do with it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you file a bug about this and CC me? you can tag it w/ clang-doc for now, even though its an issue w/ mustache lib. I can try to fix that maybe next week.

Copy link
Contributor

@ilovepi ilovepi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, except the Q on formatting. Obviously doesn't need to be solved in this patch, though.

@evelez7 evelez7 closed this Jul 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants